<?php

namespace app\api\validate;


use \think\Validate;

/**
 *  购物车验证类
 */
class Carts extends Validate
{
    protected $rule = [
        'id' => 'require',
        'user_id' => 'require|number',
        'page' => 'require|number',
        'listRows' => 'require|number',
        'product_id' => 'require|number',
        'warehouse_id' => 'require|number',
        'is_futures' => 'require|number',
        'quantity' => 'require|number',
        'sku' => 'require'
    ];

    //定义验证提示
    protected $message = [
        'id.require' => 'carts.idRequire',
        'id.number' => 'carts.idNumbe',
        'user_id.require' => 'carts.userIdRequire',
        'user_id.number' => 'carts.userIdNumbe',
        'page.require' => 'carts.pageRequire',
        'page.number' => 'carts.pageNumber',
        'listRows.require' => 'carts.listRowsRequire',
        'listRows.number' => 'carts.listRowsNumber',
        'product_id.require' => 'carts.productIdRequire',
        'product_id.number' => 'carts.productIdNumber',
        'warehouse_id.require' => 'carts.warehouseIdRequire',
        'warehouse_id.number' => 'carts.warehouseIdNumber',
        'is_futures.require' => 'carts.isFuturesRequire',
        'is_futures.number' => 'carts.isFuturesNumber',
        'quantity.require' => 'carts.quantityRequire',
        'quantity.number' => 'carts.quantityNumber',
        'sku.require' => 'carts.skuRequire',
    ];

    //定义验证场景
    protected $scene = [
        'list' => ['user_id', 'page','listRows'],
        'add' => ['user_id','product_id','warehouse_id','is_futures','quantity'],
        'update' => ['user_id','id'],
        'remove' => ['user_id','id'],
        'clearAll' => ['user_id']
    ];
}
